import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';

export const columns: BasicColumn[] = [
    {
        title: '网络组件名称',
        dataIndex: 'networkName'
    },
    {
        title: '网络类型',
        dataIndex: 'networkType_dictText'
    },
    {
        title: '网络组件状态', //0正常，1禁用
        dataIndex: 'networkStatus',
        customRender: ({ text, record }) => {
            if (record.networkStatus === 1) {
                return '禁用'
            }
            return '正常'
        },
    },
    {
        title: '服务器IP地址',
        dataIndex: 'networkIp',
    },
    {
        title: '服务器端口',
        dataIndex: 'networkPort'
    },
    {
        title: '网络组件描述',
        dataIndex: 'networkRemark'
    },
    {
        title: '创建时间',
        dataIndex: 'createTime'
    },
];

export const searchFormSchema: FormSchema[] = [
    {
        label: '网络组件名称',
        field: 'networkName',
        component: 'Input'
    },
];

export const formSchema: FormSchema[] = [
    // TODO 主键隐藏字段，目前写死为ID
    { label: '', field: 'networkId', component: 'Input', show: false },
    { label: '', field: 'isEdit', component: 'InputNumber', show: false },
    {
        label: '网络组件名称',
        field: 'networkName',
        component: 'Input',
        colProps: { span: 22 },
        rules: [{ required: true, message: "请输入网络组件名称" }],
        dynamicDisabled: ({ values }) => {
            if (values.isEdit != undefined && values.isEdit == true) {
                return true
            } else {
                return false
            }
        },
    },
    {
        label: '网络类型',
        field: 'networkType',
        component: 'JDictSelectTag',
        componentProps: {
            dictCode: "network_type",
        },
        colProps: { span: 22 },
        rules: [{ required: true, message: "请选择网络类型" }],
        dynamicDisabled: ({ values }) => {
            if (values.isEdit != undefined && values.isEdit == true) {
                return true
            } else {
                return false
            }
        },
    },
    {
        label: '网络组件状态',
        field: 'networkStatus',
        component: 'Select',
        colProps: { span: 22 },
        componentProps: {
            options: [
                {
                    label: '正常',
                    value: 0,
                },
                {
                    label: '禁用',
                    value: 1,
                },
            ],
        },
        rules: [{ required: true, message: "请选择网络组件状态" }],
        dynamicDisabled: ({ values }) => {
            if (values.isEdit != undefined && values.isEdit == true) {
                return true
            } else {
                return false
            }
        },
    },
    {
        label: '服务器IP地址',
        field: 'networkIp',
        component: 'Input',
        colProps: {
            span: 11,
        },
        rules: [{ required: true, message: "请输入服务器IP地址" }],
        dynamicDisabled: ({ values }) => {
            if (values.isEdit != undefined && values.isEdit == true) {
                return true
            } else {
                return false
            }
        },
    },
    {
        label: '服务器端口',
        field: 'networkPort',
        component: 'Input',
        colProps: {
            span: 11,
        },
        componentProps: {
            type: 'number',
        },
        rules: [{ required: true, message: "请输入服务器端口" }],
        dynamicDisabled: ({ values }) => {
            if (values.isEdit != undefined && values.isEdit == true) {
                return true
            } else {
                return false
            }
        },
    },
    {
        label: 'RTSP端口',
        field: 'networkRtspPort',
        component: 'Input',
        colProps: { span: 22 },
        ifShow: ({ values }) => {
            if (values.networkType == '3') {
                return true
            } else {
                return false
            }
        },
        rules: [{ required: true, message: "请输入RTSP端口" }],
        dynamicDisabled: ({ values }) => {
            if (values.isEdit != undefined && values.isEdit == true) {
                return true
            } else {
                return false
            }
        },
    },
    {
        label: '码流类型',
        field: 'networkStreamType',
        component: 'JDictSelectTag',
        colProps: { span: 22 },
        componentProps: {
            dictCode: "stream_type",
        }, ifShow: ({ values }) => {
            if (values.networkType == '3') {
                return true
            } else {
                return false
            }
        },
        rules: [{ required: true, message: "请选择码流类型" }],
        dynamicDisabled: ({ values }) => {
            console.log(4444444);
            console.log(values);


            if (values.isEdit != undefined && values.isEdit == true) {
                return true
            } else {
                return false
            }
        },
    },
    // {
    //   label: '服务器账号',
    //   field: 'networkAccount',
    //   component: 'Input',
    //   rules: [{ required: true, message: "请输入服务器账号" }],
    //   dynamicDisabled: ({ values }) => {
    //     if (values.isEdit != undefined && values.isEdit == true) {
    //       return true
    //     } else {
    //       return false
    //     }
    //   },
    // },
    // {
    //   label: '服务器密码',
    //   field: 'networkPassword',
    //   component: 'Input',
    //   rules: [{ required: true, message: "请输入服务器密码" }],
    //   dynamicDisabled: ({ values }) => {
    //     if (values.isEdit != undefined && values.isEdit == true) {
    //       return true
    //     } else {
    //       return false
    //     }
    //   },
    // },
    {
        label: '网络组件描述',
        field: 'networkRemark',
        component: 'Input',
        colProps: { span: 22 },
        dynamicDisabled: ({ values }) => {
            if (values.isEdit != undefined && values.isEdit == true) {
                return true
            } else {
                return false
            }
        },
    }
];
